#include <Windows.h>

#include "CChar.h"
#include "CTradeContainer.h"
#include "CSynthResultShowPacket.h"

CSynthResultShowPacket::CSynthResultShowPacket(unsigned short itemID, unsigned char quantity, unsigned char synthResult, CChar * schar) {
	this->type = 0x70;
	this->size = 0x18;
	memset(data, 0, sizeof(data));

	data[0x04-0x04] = synthResult;

	data[0x06-0x04] = quantity;
	memcpy(data+0x08-0x04, &itemID, 2);
	memcpy(data+0x1E-0x04, schar->m_name, 16);
}

CSynthResultShowPacket::CSynthResultShowPacket(CTradeContainer * synthContainer, unsigned char synthResult, CChar * schar) {
	this->type = 0x70;
	this->size = 0x18;
	memset(data, 0, sizeof(data));

	data[0x04-0x04] = synthResult;
	memcpy(data+0x1E-0x04, schar->m_name, 16);

	unsigned char count = 0;
	for(unsigned char slotID = 1; slotID <= 8; slotID++) {
		unsigned long quantity = 0;
		quantity = synthContainer->getQuantity(slotID);
		if(quantity == 0) {
			unsigned short itemID = 0;
			itemID = synthContainer->getItemID(slotID);
			memcpy(data+0x0a+(count * 0x02)-0x04, &itemID, 2);
			count++;
		}
	}
}


CSynthResultShowPacket::~CSynthResultShowPacket() {
}